﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using FortisBC.Internet.Core.Utilities;

namespace FortisBC.EnergyEfficiencyCalculator
{
    public partial class CalculatorControl : UserControl
    {
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (this.WebPart != null)
            {
                this.lblRate.Text = this.WebPart.Rate;
            }

            RegisterClientSideArtifacts();
        }
        
        public CalculatorWebPart WebPart { get; set; }

        private void RegisterClientSideArtifacts()
        {
            // register CSS
            CssRegistrationUtility.RegisterThemableCssLink(this, ClientSideArtifacts.EnergyEfficiencyCalculatorCssFile);

            // register jQuery script library
            ScriptRegistrationUtility.RegisterClientScriptInclude(this, ClientSideArtifacts.JQueryScriptFile);

            // register jQuery Calculation script library
            ScriptRegistrationUtility.RegisterClientScriptInclude(this, ClientSideArtifacts.JQueryCalculationScriptFile);

            // register Calculator library
            ScriptRegistrationUtility.RegisterClientScriptInclude(this, ClientSideArtifacts.EnergyEfficiencyCalculatorScriptFile);
        }
    }
}
